package com.leetcode.题库.score1;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @BelongsProject: LeetCode
 * @BelongsPackage: com.leetcode.题库.score1
 * @Author: lei
 * @CreateTime: 2024-03-25  19:23
 * @Description: TODO
 * @Version: 1.0
 */
public class 多个数组按顺序合并 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = Integer.parseInt(scanner.nextLine());
        ArrayList<String> arrayList = new ArrayList<>();
        while (!scanner.hasNext("#")) {
            String s = scanner.nextLine();
            arrayList.add(s);
        }
        StringBuilder builder = new StringBuilder();
        int index = 0;
        while (index < arrayList.size()) {
            String s = arrayList.get(index);
            if (s.length() <= number) {
                builder.append(s).append(",");
            } else {
                if (s.length() < 6) {
                    builder.append(s, 0, s.length()).append(",");
                } else {
                    builder.append(s, 0, 6);
                    arrayList.add(s.substring(6));
                }
            }
            index++;
        }
        System.out.println(builder.deleteCharAt(builder.length() - 1));
    }
}
